package com.topisv.tms.task.warehouseage;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.topisv.tms.service.WarehouseAgeService;
import com.topisv.tms.service.task.ScheduledTaskService;

/**
 * 库龄计算
 *  Date          Author       Version       Description
 * ----------------------------------------------------------
 *  2015-7-1      GaoHuan            1.0           Create
 */
@Component
//@Lazy(false)
public class CountWarehouseAgeTaskProvider {
	private Logger logger = LoggerFactory.getLogger(getClass());
	
	@Autowired
	private WarehouseAgeService service;
	@Autowired
	private ScheduledTaskService scheduledTaskService;
//	@Scheduled(cron = "0 22 11 1 * *")
//	@Async
	public void executor() {
		try {
//			try {
//				scheduledTaskService.lock();
//			} catch (Exception e) {
//			}
//			boolean rs = scheduledTaskService.check();
//			if (rs) {
				service.goodsAge();
//			}
		} catch (Exception e) {
			e.printStackTrace();
			logger.error("CountWarehouseAgeTaskProvider case some error.", e);
		}
	}

}
